<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!-- 2、实现一个数组扁平化函数flattenDeep(要求使用reduce方法实现)
* 输入: [1, [2, 3], [[4, [5, 6]]]]
* 输出: [1, 2, 3, 4, 5, 6] -->

<body>
    <div>test12-2</div>
    <script>
        function flatten(arr) {
            return arr.reduce((total, current) => {
                return total.concat(Array.isArray(current) ? flatten(current) : current);
            }, []);
        }
        console.log(flatten([1, [2, 3], [[4, [5, 6]]]]))
    </script>
</body>

</html>